/**
 * Created by duixintong on 2018/9/21.
 */
import axios from 'axios'
export default {
  changeUserTel (state, userTel) {
    state.userTel = userTel
    try {
      localStorage.userTel = userTel
    } catch (e) {}
  },
  changeUserToken (state, userToken) {
    state.token = userToken
    try {
      localStorage.token = userToken
    } catch (e) {}
  },
  changeProduct(state,product){
    state.product = product
  },
  changeConditions(state,con){
    state.conditions = con
  },
  getMarriedList(state){
    axios({
      method: 'GET',
      url: '/h5api/as/common/dictionary',
      params: {
        dicKey: 'marriStatus'
      }
    }).then((res) => {
      res = res.data
      if (res.code === 200) {
        state.marriedList= res.data
      }
    })
  },
  getAreaInfo(state){
    axios({
      method: 'GET',
      url: '/h5api/as/common/location/provinceCityDistrict'
    }).then((res) => {
      res = res.data;
      if (res.code === 200) {
        let data = res.data;
        state.areaList=data

      } else {
        this.$toast(res.msg)
      }
    })
  },
  getXlList(state){
    axios({
      method: 'GET',
      url: '/h5api/as/common/dictionary',
      params: {
        dicKey: 'education'
      }
    }).then((res) => {
      res = res.data;
      if (res.code === 200) {
        let data = res.data;
        state.xlList=data
      } else {
        this.$toast(res.msg)
      }
    })
  },
  getTermOptions(state,id){
    axios({
      method:'GET',
      url:`/list/as/app/financial/normal/LoanSupermarketProduct/termOption/${id}`
    }).then((res)=>{
      res=res.data;
      if(res.code===200){
        state.termOptions= res.data;
      }else {
        this.$toast(res.msg)
      }
    })
  }
}
